<template>
<view>
<view v-if="carList.length>0">
    <view class="shop_border">
        <view v-for="(item, indexs) in carList" :key="indexs" class="shop_modle" :hidden="plate_type!=1">
            <view class="shop_modle_headImg_view">
                <image @tap="store" class="shop_modle_headImg" :data-uid="item.uid" :src="item.head_image.head_image"></image>
                <view class="shop_modle_headImg_view_btmTextView" v-if="item.top_status">推荐</view>
            </view>
            <view class="shop_modle_right">
                <view @tap="detile" :data-id="item.id">
                    <view class="shop_modle_right_title">
                        <text class="shop_modle_right_title_name">{{item.head_image.nickname?item.head_image.nickname:item.username}}</text>
                        <text class="ziying" v-if="item.uid==0">自营</text>
                        <text class="shop_modle_right_title_right">{{item.price}}万</text>
                    </view>
                    <view class="shop_modle_message">
                        <text style="font-weight:normal"></text> 【{{item.name}}】 {{item.km}}公里 {{item.agelimit==0?'全新车':'车龄 '+item.agelimit+'年'}}</view>
                    <view class="shop_modle_area">
                        <text class="shop_modle_area_dian">·</text>{{item.timestr}}·{{item.caraddress}}</view>
                </view>
                <scroll-view class="solid_modle_scroll" scroll-x="true">
                    <view v-for="(item, index) in item['image']" :key="index" class="solid_modle_scroll_modle">
                        <image @tap="previewImage" class="solid_modle_scroll_modle_img" :data-index="index" :data-src="item.img_patch" :src="item.img_patch"></image>
                    </view>
                </scroll-view>
                <view class="shop_modle_num">浏览 {{item.browse}}</view>
            </view>
        </view>
        <view class="btm_nav"></view>
    </view>
</view>
<view v-for="(item, indexs) in carList" :key="indexs" class="modle" :hidden="plate_type!=2">
    <view class="tuijian" v-if="item['top_status']">推荐</view>
    <image @tap="detile" class="modle_img" :data-id="item.id" mode="aspectFill" :src="item.carimg"></image>
    <view @tap="detile" class="message_border" :data-id="item.id">
        <view class="modle_name">
            <view class="ziying" v-if="item.is_vip==1">认证车商</view>
            <view class="ziying" v-if="item.uid==0">自营</view> <!-- {{item.exhaust}} -->
            {{item.name}} {{item.agelimit==0?'全新车':'车龄 '+item.agelimit+'年'}}   {{item.gearbox==0?'手自一体':''}}{{item.gearbox==2?'手动档':''}}{{item.gearbox==2?'手自一体':''}}{{item.gearbox==2?'自动档':''}}</view>
        <view class="modle_chexing"> {{item.year}}  | {{item.km}}万公里
                </view>
        <view class="modle_price">{{item.price}}万
        </view>
    </view>
</view>
<block v-if="carList.length<=0">
    <!--<import src="/pages/data_null/index.wxml"></import>-->
    <view>
        <block data-type="template" data-is="title" data-attr="title:title">
    <view class="zanwushuju_border">
        <image class="zanwushuju_border_img" src="/static/pages/image/none_message.png"></image>
        <view class="zanwushuju_border_title">{{'暂无收藏数据'}}</view>
    </view>
</block>
    </view>
</block>
</view>
</template>

<script>
function _toConsumableArray(t) {
  if (Array.isArray(t)) {
    for (var a = 0, e = Array(t.length); a < t.length; a++) e[a] = t[a];

    return e;
  }

  return Array.from(t);
}
var app = getApp();

export default {
  data() {
    return {
      leftid: 1,
      check_name: "",
      carList: [],
      show: !0,
      name: "",
      title: "没有匹配结果，换个关键词吧！",
      plate_type: 1
    };
  },

  components: {},
  props: {},
  onLoad: function (t) {
    this.name = t.name, this.listFun(), this.info_setFun();
  },
  onReachBottom: function () {
    this.show && this.listFun();
  },
  methods: {
    info_setFun: function () {
      var a = this;
      app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          r: "home.index.info_set"
        },
        cachetime: "0",
        success: function (t) {
          2 == t.data.data.plate_type && a.setData({
            plate_type: 2
          });
        }
      });
    },
    listFun: function () {
      var e = this;
      app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          r: "home.index.search_index",
          name: this.name,
          leftid: this.leftid++
        },
        cachetime: "0",
        success: function (t) {
          var a;
          (console.log(t), 0 < t.data.data.length) ? ((a = e.carList).push.apply(a, _toConsumableArray(t.data.data)), e.setData({
            carList: e.carList
          })) : e.show = !1;
        }
      });
    },
    detile: function (t) {
      var a = app.globalData.getAttr(t, "id");
      wx.navigateTo({
        url: "/pagesA/home/carMessage/carMessage?id=" + a
      });
    },
    previewImage: function (t) {
      var a = app.globalData.getAttr(t, "src"),
          e = app.globalData.getAttr(t, "index");
      console.log(e);
      var r = [],
          i = !0,
          n = !1,
          s = void 0;

      try {
        for (var o, c = this.carList[e].image[Symbol.iterator](); !(i = (o = c.next()).done); i = !0) {
          var p = o.value;
          r.push(p.img_patch);
        }
      } catch (t) {
        n = !0, s = t;
      } finally {
        try {
          !i && c.return && c.return();
        } finally {
          if (n) throw s;
        }
      }

      wx.previewImage({
        current: a,
        urls: r
      });
    },
    store: function (t) {
      var a = app.globalData.getAttr(t, "uid");
      wx.navigateTo({
        url: "/pages/store/index?uid=" + a
      });
    }
  }
};
</script>
<style>
@import "./index.css";
</style>